from rest_framework import serializers
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory


# 频道页面序列化器
class CategoriesSerializer(serializers.ModelSerializer):
    category = serializers.StringRelatedField(read_only=True)
    category_id = serializers.IntegerField()

    group = serializers.StringRelatedField(read_only=True)
    group_id = serializers.IntegerField()

    class Meta:
        model = GoodsChannel
        fields = "__all__"


# 新增频道 频道组获取序列化器
class GoodsChannelGroupSerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsChannelGroup
        fields = ("id", "name")


# 新增频道 一级分类获取序列化器
class GoodsChannelCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields = ("id", "name")
